<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Vue模板插值</title>
    <script src="https://unpkg.com/vue@3.4.0"></script>
  </head>
  <body>
    <div id="app">
      <!-- 双大括号插值 -->
      <h1>{{title}}</h1>

      <!-- v-text指令 -->
      <div v-text="message"></div>

      <!-- v-html指令 -->
      <div v-html="htmlContent"></div>

      <!-- v-once一次性插值 -->
      <p v-once>这个值只会渲染一次：{{count}}</p>
      <p>这个值会响应式更新：{{count}}</p>

      <button @click="count++">点击增加</button>
    </div>

    <script>
      const { createApp, ref } = Vue

      const App = {
        setup() {
          const title = ref('你的待办事项')
          const message = ref('欢迎使用Vue模板插值')
          const htmlContent = ref("<p style='color:red'>这是HTML内容</p>")
          const count = ref(0)

          return {
            title,
            message,
            htmlContent,
            count
          }
        }
      }

      createApp(App).mount('#app')
    </script>
  </body>
</html>
